﻿using BotDetector.Core.Utilities;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;

namespace BotDetector.Core.NaiveBayesModule
{
    public class BayesTrainer
    {
        BayesFileOperator bayesFileReader = new BayesFileOperator();

        public void CreateTrainFile(){
            BayesClassifier classifier;

            List<Document> trainCorpus = InitTrainCorpus();

            classifier = new BayesClassifier();
            classifier.Train(trainCorpus);

            bayesFileReader.SaveClassifier(classifier);
        }

        private List<Document> InitTrainCorpus()
        {
            List<Document> trainCorpus = new List<Document>();

            trainCorpus.AddRange(bayesFileReader.GetNonbotDocumentSet());
            trainCorpus.AddRange(bayesFileReader.GetBotDocumentSet());

            return trainCorpus;
        }
    }
}
